package ModelLag;

import java.util.ArrayList;
import java.util.GregorianCalendar;

/**
 * Modelklasse for WorkingPlan.
 * @author DM75 Gruppe 3
 * @version 2011-12-22
 */
public class WorkingPlan {
    private GregorianCalendar date;
    private String location;
    private ArrayList<Shift> shifts;
    
    public WorkingPlan()
    {
        
    }

    public WorkingPlan(GregorianCalendar date, String location, ArrayList<Shift> shifts) {
        this.date = date;
        this.location = location;
        this.shifts = shifts;
    }
    
    public void addShiftToWorkingPlan(Shift newShift)
    {
        getShifts().add(newShift);
    }
    
    public void removeShiftFromWorkingPlan(Shift shiftObj)
    {
        getShifts().remove(shiftObj);
    }
    
    public Shift findShift(Employee empObj, String startTime, String endTime)
    {
        int index = 0;
        boolean found = false;
        
        Shift shiftObj = null;
        
        while(index < getShifts().size() && !found)
        {
            shiftObj = getShifts().get(index);
            
            if(shiftObj.getEmployee().equals(empObj) && shiftObj.getStartTime().equals(startTime) && shiftObj.getEndTime().equals(endTime))
            {
                found = true;
            }
            else
            {
                index++;
            }
        }
        if(found)
        {
            return getShifts().get(index);
        }
        else
        {
            return null;
        }
    }

    /**
     * @return the date
     */
    public GregorianCalendar getDate() {
        return date;
    }

    /**
     * @param date the date to set
     */
    public void setDate(GregorianCalendar date) {
        this.date = date;
    }

    /**
     * @return the location
     */
    public String getLocation() {
        return location;
    }

    /**
     * @param location the location to set
     */
    public void setLocation(String location) {
        this.location = location;
    }

    /**
     * @return the shifts
     */
    public ArrayList<Shift> getShifts() {
        return shifts;
    }

    /**
     * @param shifts the shifts to set
     */
    public void setShifts(ArrayList<Shift> shifts) {
        this.shifts = shifts;
    }
    
    
    
}
